#!/bin/bash
#SQOOP_HOME=/opt/cloudera/parcels/CDH-6.2.1-1.cdh6.2.1.p0.1425774/bin/sqoop
SQOOP_HOME=/usr/bin/sqoop
if [[ $1 == "" ]];then
   TD_DATE=`date -d '1 days ago' "+%Y-%m-%d"`
else
   TD_DATE=$1
fi

echo '========================================'
echo '==============开始全量导入==============='
echo '========================================'




sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'select id, school_id, subject_id, class_id, ifnull(studying_student_count,0) studying_student_count, studying_date, FROM_UNIXTIME(unix_timestamp(),"%Y-%m-%d") as dt from class_studying_student_count where $CONDITIONS' \
--hcatalog-database itcast_dwd \
--hcatalog-table fact_class_studying_student_count \
-m 3 \
--split-by id


sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'select id,
    base_id,
    class_id,
    class_date,
    content,
    teacher_id,
    teacher_name,
    job_number,
    classroom_id,
    classroom_name,
    is_outline,
    class_mode,
    is_stage_exam,
    is_pay,
    tutor_teacher_id,
    tutor_teacher_name,
    tutor_job_number,
    is_subsidy,
    answer_teacher_id,
    answer_teacher_name,
    answer_job_number,
    remark,
    create_time,
    FROM_UNIXTIME(unix_timestamp(),"%Y-%m-%d") as dt from course_table_upload_detail where $CONDITIONS' \
--hcatalog-database itcast_dwd \
--hcatalog-table dim_course_table_upload_detail \
-m 3 \
--split-by id





sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'select *, FROM_UNIXTIME(unix_timestamp(),"%Y-%m-%d") as dt from tbh_class_time_table where $CONDITIONS' \
--hcatalog-database itcast_dwd \
--hcatalog-table dim_class_time \
-m 3 \
--split-by id





sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'select *, FROM_UNIXTIME(unix_timestamp(),"%Y-%m-%d") as dt from tbh_student_signin_record where $CONDITIONS' \
--hcatalog-database itcast_dwd \
--hcatalog-table fact_student_signin \
-m 3 \
--split-by id





sqoop import \
--connect jdbc:mysql://106.75.33.59:3306/teach \
--username itcast_edu_stu \
--password itcast_edu_stu \
--query 'select *, FROM_UNIXTIME(unix_timestamp(),"%Y-%m-%d") as dt from student_leave_apply where $CONDITIONS' \
--hcatalog-database itcast_dwd \
--hcatalog-table fact_student_leave_apply \
-m 3 \
--split-by id
